package com.dc.kylin.logbackdesensitization.controller;

import com.dc.kylin.logbackdesensitization.entity.UserInfo;
import com.dc.kylin.logbackdesensitization.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/user")
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/create")
    public UserInfo createUser(@RequestBody UserInfo userInfo) {
        log.info("接收到创建用户请求: {}", userInfo);
        return userService.createUser(userInfo);
    }

    @GetMapping("/{userId}")
    public UserInfo getUser(@PathVariable String userId) {
        log.info("查询用户信息, userId: {}", userId);
        return userService.getUserDetail(userId);
    }

    @PostMapping("/batch")
    public String batchProcess(@RequestBody String userData) {
        // 模拟处理大量数据，测试高并发脱敏
        log.info("批量处理用户数据: {}", userData);
        return "处理成功";
    }
}
